package com.wangmengtao.upms.controller;

import com.wangmengtao.upms.model.UpmsRole;
import com.wangmengtao.upms.service.UpmsRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: UpmsRoleController
 * @Description: TODO
 * @Author: WangMengtao
 * @Data: 2019/6/5 17:15
 * @Version: 1.0.0
 */
@RestController
public class UpmsRoleController {

    @Autowired
    private UpmsRoleService upmsRoleService;

    @PostMapping(value = "/roles")
    public Object create(UpmsRole upmsRole) {
        return upmsRoleService.insert(upmsRole);
    }

    @DeleteMapping(value = "/roles/{id}")
    public Object deleteById(@PathVariable("id") Long id) {
        return upmsRoleService.deleteById(id);
    }

    @PutMapping(value = "/roles")
    public Object update(UpmsRole upmsRole) {
        return upmsRoleService.update(upmsRole);
    }

    @GetMapping(value = "/roles/{id}")
    public Object getByid(@PathVariable("id") Long id) {
        return upmsRoleService.getById(id);
    }

    @GetMapping(value = "/roles")
    public Object list() {
        return upmsRoleService.list();
    }
}
